package com.bw.concer;

import com.bw.bean.Sst;
import com.bw.bean.User;
import com.bw.service.UserService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserConcer {
    @Autowired
    UserService userService;
    @RequestMapping("list")
    public Map list(){
        Double list=userService.list();
        HashMap<Object, Object> map = new HashMap<>();
                      map.put("status",0);
                map.put("data",list);
        return  map;
    }
    @RequestMapping("list2")
    public Map list2(){
        List<User> list=userService.list1();
        return SugarUtil.getPieData(list);
    }
    @RequestMapping("list3")
    public String list3(){
        List<Sst> list=userService.list3();
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("机构");
        list1.add("次数");
        list1.add("距离");
        list1.add("时间");
        list1.add("平均距离");
        list1.add("平均时间");
        return SugarUtil.getTablePlayData(list1,list);
    }
    @RequestMapping("list4")
    public Map list4(){
        List<User> list=userService.list4();
        return SugarUtil.getMapData(list);
    }
}
